
#include "store.h"
#include "nvm.h"
#include "stdio.h"



uint8_t product_arry[20] = {0XCC,1,2,3,4,5,6,7,8,9,89};

// 存储信息结构

STR_MESSAGE_FORMAT infor = 
{
    .head_start = 0X40,
    .record_total_num = 0XAAAAAAAA,
    .ctrl_addr = 2,
    .controller_type = 0x3333,
    .product_code = {0XFF,0XFF,0XFF},
    .data_infor = {
        .controllerr_num = 0X4455,
        .unity_num = 6,
        .channel_num = 7,
        .device_num = 8,
    
        .statue_type = 0X9999,
        .year = 10,
        .month = 11,
        .day = 12,
        .hours = 13,
        .minute = 34,
        .second = 56,
    },
    .CRC = 0XBBBB,
    .stop_end = 0X41
};


void make_fram(uint16_t event)
{
     infor.data_infor.event_type = event;
}

int main()
{
    printf("utest is start\r\n");
    int i = 203;
    int j = 300;
    uint8_t arry[64]= {0};
    
    store_index_init();
    read_index_init();

    make_fram(FAULT_CODE_LOW);
     while (i--)
    {
        infor.record_total_num = i;
        store_new_message_to_in_flash(&infor);
    }

    i = 129;
    make_fram(FIRST_ALALRM_CODE);
     while (i--)
    {
        infor.record_total_num = i;
        store_new_message_to_in_flash(&infor);
    }

    read_ctrl_message_add(ENU_ALARM);
    read_ctrl_message_add(ENU_FIRST_FIRE);
    read_ctrl_message_add(ENU_FAULT);
    

     while (j--)
     {
        read_ctrl_schdule();
        
     }
printf("---------------------------------------");
    read_ctrl_message_add(ENU_OTHER);
    
    read_ctrl_message_add(ENU_FAULT);
    
    j = 500;
    while (j--)
     {
        read_ctrl_schdule();
        
     }


//     c_bzero(&product_arry[3],4);
    
// for(int i = 0; i<20;i++)
// {
//     printf("%d \n",product_arry[i]);

// }

    //printf("get_type_record_total_num %d\n",get_type_record_total_num(ENU_FIRST_FIRE) );

    StrNvmOperaTable.pNVM_flash_print(DIDEX_RECORD_INDEX,0,10);
 

    // StrNvmOperaTable.pNVM_flash_print(DIDEX_OUT_FIRST_FIRE_RECORD,0,2048);
    //  StrNvmOperaTable.pNVM_flash_print(DIDEX_IN_FIRST_FIRE_RECORD,0,2048);

}


